<html>
<head>
<SCRIPT language='JavaScript'>

var http = createRequestObject();
var http2= createRequestObject();
function decode(str) {
var result = "";
	for (i = 0; i< str.length; i++) {
		if (str.charAt(i) == "+") result += " ";
		else result += str.charAt(i);
	}
	return unescape(result);
}


function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
	
        ro = new ActiveXObject("Microsoft.XMLHTTP");

    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

function listParticipant(){
   var url="http://jeremi.info/~crowdup/getParticipant.php?manif=1";
    showMsg("sndReq <a href='"+ url + "'> contenu colonne </a>");
    try {
	    http2.open('get', url);
	    http2.onreadystatechange = handleResponse2;
	    http2.send(null);
	} catch(e){
		alert("sndReq  :" + e.name + ". Error message: " + e.message);	
	}

}
function listManifestation() {
    var url="http://jeremi.info/~crowdup/getManifestation.php?";
    showMsg("sndReq <a href='"+ url + "'> contenu colonne </a>");
    try {
	    http.open('get', url);
	    http.onreadystatechange = handleResponse;
	    http.send(null);
	} catch(e){
		alert("sndReq  :" + e.name + ". Error message: " + e.message);	
	}
}
function trim(sString)
{

	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}



function handleResponse() {
    if(http.readyState == 4){
	
	try {
      	var response = http.responseText;
		showMsg("handleResponse ");
		showMsg(response);
		var DESCRIPTOR = eval("("+response+")");
		
		var text="";
		for (key in DESCRIPTOR["manifestations"]) {
			createMarker(DESCRIPTOR["manifestations"][key]["longitude"],DESCRIPTOR["manifestations"][key]["latitude"]);
		}
	} catch(e) {
		alert("handleResponse  exception: " + e.name 
+ ". Error message: " + e.message);	
	}
   }
}

function handleResponse2() {
    if(http.readyState == 4){
	
	try {
      	var response = http.responseText;
		showMsg("handleResponse ");
		showMsg(response);
		var DESCRIPTOR = eval("("+response+")");
		
		var text="";
		for (key in DESCRIPTOR["points"]) {
			createMarker(DESCRIPTOR["points"][key]["longitude"],DESCRIPTOR["points"][key]["latitude"]);
		}
	} catch(e) {
		alert("handleResponse  exception: " + e.name 
+ ". Error message: " + e.message);	
	}
   }
}


function showMsg(msg) {
	document.getElementById("debug").innerHTML+= "<br>"+msg;
}
function createMarker(x,y) {
	showMsg(x+"!"+y);
}
// mouse moves


</SCRIPT>
</head>
<body>
<input type="submit" onclick="javascript:listManifestation();" value="MANIFS">
<input type="submit" onclick="javascript:listParticipant();" value="PARTICIPANTS">
<div id="debug">

</div>
</body>
</html>